package com.mlnx.stream.listener.iml;

import com.mlnx.common.utils.MyLog;
import com.mlnx.data.entity.SpoInfo;
import com.mlnx.data.service.SpoDataService;
import com.mlnx.stream.listener.SpoListener;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;

import cn.hutool.core.date.DateUtil;

/**
 * Created by amanda.shan on 2019/10/27.
 */
@Component
public class SpoStoreListener implements SpoListener {

    private MyLog log = MyLog.getLog(getClass());

    @Autowired
    private SpoDataService spoDataService;

    @Override
    public void receiveSpoInfo(SpoInfo spoInfo) {

        spoDataService.save(spoInfo);
        log.debug("保存SPOINFO 病人ID：{} {} {}", spoInfo.getPatientId(),
                spoInfo.getResultSPO(),
                DateUtil.formatDateTime(new Date(spoInfo.getTime())));
    }

}
